package org.yt.util;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 创建与数据库连接工厂
 * @author Administrator
 *
 */
public class ConnFactory {

	private static Connection conn;
	private static String url = "jdbc:mysql://localhost:3306/bloguse?Unicode=true&characterEncoding=utf8&autoReconnect=true";
	private static String user = "root";
	private static String password = "123";
	
	static{
		if(conn == null){
			try {
				Class.forName("com.mysql.jdbc.Driver");
				conn = DriverManager.getConnection(url, user, password);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static Connection getConn() {
		return conn;
	}
	
}
